package com.jiangjiang.eshop.schedule.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiangjiang.eshop.schedule.convert.ScheduleOrderSendOutDetailConvert;
import com.jiangjiang.eshop.schedule.dao.ScheduleOrderSendOutDetailMapper;
import com.jiangjiang.eshop.schedule.domain.ScheduleOrderSendOutDetailEntity;
import com.jiangjiang.eshop.schedule.dto.ScheduleOrderSendOutDetailDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ScheduleOrderSendOutDetailService
 * @Description TODO
 * @Author jhw
 * @Date 2021/8/31 7:06
 * @Version 1.0
 **/
@Service
public class ScheduleOrderSendOutDetailService extends ServiceImpl<ScheduleOrderSendOutDetailMapper, ScheduleOrderSendOutDetailEntity> {
    @Autowired
    private ScheduleOrderSendOutDetailConvert scheduleOrderSendOutDetailConvert;

    /**
     * 根据订单id和订单条目id查询发货明细
     * @param orderInfoId 订单id
     * @param orderItemId 订单条目id
     * @return 发货明细
     * @throws Exception
     */
    public List<ScheduleOrderSendOutDetailDTO> listByOrderItemId(Long orderInfoId, Long orderItemId) {
        LambdaQueryWrapper<ScheduleOrderSendOutDetailEntity> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(ScheduleOrderSendOutDetailEntity::getOrderInfoId, orderInfoId)
                .eq(ScheduleOrderSendOutDetailEntity::getOrderItemId, orderItemId);
        return scheduleOrderSendOutDetailConvert.convertEntities2DTOList(this.list(wrapper));
    }
}
